import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:hippo_app/values/color_value.dart';
import 'package:hippo_app/values/size_value.dart';
import 'package:hippo_app/values/style_value.dart';

class LineTitle extends StatelessWidget {
  final MainAxisAlignment mainAxisAlignment;
  final CrossAxisAlignment crossAxisAlignment;
  final double lineWidth;
  final double lineHeight;
  final Color lineColor;
  final String title;
  final TextStyle? style;
  final double bottom;
  final bool lineVisible;
  final Widget? rightWidget;

  const LineTitle({
    super.key,
    required this.title,
    this.mainAxisAlignment = MainAxisAlignment.spaceBetween,
    this.crossAxisAlignment = CrossAxisAlignment.center,
    this.lineWidth = 4,
    this.lineHeight = 16,
    this.lineColor = ColorValue.appPrimaryColor,
    this.style,
    this.bottom = 10,
    this.lineVisible = true,
    this.rightWidget,
  });

  @override
  Widget build(BuildContext context) {
    return Row(
      mainAxisAlignment: mainAxisAlignment,
      crossAxisAlignment: crossAxisAlignment,
      children: [
        Row(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            if (lineVisible)
              Container(
                width: lineWidth,
                height: lineHeight,
                margin: EdgeInsets.only(bottom: bottom),
                decoration: BoxDecoration(
                  borderRadius: BorderRadius.all(
                    Radius.circular(SizeValue.appBorderRadius),
                  ),
                  color: lineColor,
                ),
              ),
            Container(
              margin: EdgeInsets.only(
                left: lineVisible ? 5 : 0,
                bottom: bottom,
              ),
              child: Text(title, style: style ?? StyleValue.titleStyle),
            ),
          ],
        ),
        Container(
          margin: EdgeInsets.only(left: lineVisible ? 5 : 0, bottom: bottom),
          child: rightWidget ?? Container(),
        ),
      ],
    );
  }
}
